<?php require_once ADMINVIEWPATH.'admin_header.php'; ?>
<?php require_once ADMINVIEWPATH.'admin_menu.php'; ?>
<!-- Page Content -->
            <div class="page-content">
                <!-- Page Breadcrumb -->
                <div class="page-breadcrumbs">
                    <ul class="breadcrumb">
                        <li>
                            <i class="fa fa-home"></i>
                            <a href="/luckydog/index">首页</a>
                        </li>
                        <li>
                            <a href="#">评论管理</a>
                        </li>
                        <li class="active">
                            评论列表
                        </li>
                    </ul>
                </div>
                <!-- /Page Breadcrumb -->
                <!-- Page Body -->
                <div class="page-body">
                    <div class="row">
                        <div class="col-xs-12 col-md-12">
                            <div class="tab-content tabs-flat no-padding">
                                <div id="visits" class="tab-pane active animated fadeInUp">
                                    <div class="row">
                                        <div class="col-lg-12 chart-container">
                                            <div id="dashboard-chart-visits" class="chart chart-lg no-margin">
                                                <div class="widget-body">
                                                    <!-- <div style="float: left;">
                                                        从：<input class="form-control" style="width:100px;" type="text" placeholder="起始时间" id="starttime" onClick="WdatePicker()" value="">
                                                        到：<input class="form-control" style="width:100px;" type="text" placeholder="结束时间" id="endtime" onClick="WdatePicker()" value="">
                                                    </div> -->
                                                    <div class="pull-left" style="line-height: 30px;margin-left: 10px;margin-bottom: 20px;">关键字：</div>
                                                    <div style="float: left; padding-left:10px;">
                                                        <input class="form-control pull-left" style="width:100px;" placeholder="关键字" id="content" type="text">
                                                    </div>
                                                    <div class="pull-left" style="line-height: 30px;margin-left: 10px;">新闻ID:</div>
                                                    <div style="float: left; padding-left:10px;">
                                                        <input class="form-control" style="width:150px;" placeholder="新闻ID" id="newsid" type="text">
                                                    </div>
                                                    <div class="control-group"  style="float: left; padding-left:50px;">
                                                        <div class="controls" >
                                                            <select id="status" style="width: 150px;">
                                                                <option  value = "">不限</option>
                                                                <option <?php if($status === 0):?>selected="selected"<?php endif?> value = "0">待审核</option>
                                                                <option <?php if($status == 1):?>selected="selected"<?php endif?> value = "1">已通过</option>
                                                                <option <?php if($status == 2):?>selected="selected"<?php endif?> value = "2">未通过</option>
                                                                <option <?php if($status == -1):?>selected="selected"<?php endif?> value = "-1">已删除</option>
                                                            </select>
                                                        </div>
                                                    </div>
                                                    <div style="float: left;">
                                                        <a class="btn J_search" href="javascript:;">搜索</a>
                                                    </div>
                                                    <div class="widget-title"> <span class="icon"><i class="icon-th"></i></span>
                                                        <h5 style="float: right">共有数据：<?= $total_rows;?>条</h5>
                                                    </div>
                                                    <table class="table table-striped table-bordered table-hover" id="simpledatatable">
                                                        <thead>
                                                            <tr>
                                                                  <th>ID</th>
                                                                  <th>newsID</th>
                                                                  <th>来源</th>
                                                                  <th>内容</th>
                                                                  <th>时间</th>
                                                                  <th>状态</th>
                                                                  <th>操作</th>
                                                            </tr>
                                                        </thead>
                                                        <tbody>
                                                        
                                                        <?php if(!empty($reviewList)):?>
                                                        <?php foreach($reviewList as $key=> $row):?>
                                                        <tr class="gradeX">
                                                                <td class="center" style="text-align:center;"><?= $row['reviewId'];?></td>
                                                                <td class="center"><?= $row['newsID']?></td>
                                                                <td class="center"><?= $row['fromUsername']?></td>
                                                                <td class="center"><?= cutstr($row['content'], 30)?></td>
                                                                <td class="center"><?=  date("Y-m-d h:i:s",$row['createtime'])?></td>
                                                                <td class="center">
                                                                    <?php if($row['status'] == 0){?>
                                                                        待审核
                                                                    <?php }elseif($row['status'] == 1){?>
                                                                        <span style="color:green;">已通过</span>
                                                                    <?php }elseif($row['status'] == -1){?>
                                                                        <span style="color:red;">已删除</span>
                                                                    <?php }elseif($row['status'] == 2){?>    
                                                                        <span style="color:yellow;">未通过</span>
                                                                    <?php }?>
                                                                </td>
                                                                <td class="center " data_status="<?= $row['status'];?>" data_id = "<?= $row['reviewId'];?>">
                                                                    <?php if($row['status'] == 0):?>
                                                                        <?php if(check_authorize("Review","List","verify")):?>
                                                                        <a href="javascript:;" class="edit_status" data_status = "1">通过</a>|
                                                                        <a href="javascript:;" class="edit_status" data_status = "2">不通过</a>|
                                                                        <?php endif;?>
                                                                        <?php if(check_authorize("Review","List","delete")):?>
                                                                        <a href="javascript:;" class="edit_status" data_status = "-1">删除</a>
                                                                        <?php endif;?>
                                                                    <?php elseif($row['status'] == 1):?>
                                                                        <?php if(check_authorize("Review","List","verify")):?>
                                                                        <a href="javascript:;" class="edit_status" data_status = "2">不通过</a>|
                                                                        <?php endif;?>
                                                                        <?php if(check_authorize("Review","List","delete")):?>
                                                                        <a href="javascript:;" class="edit_status" data_status = "-1">删除</a>
                                                                        <?php endif;?>
                                                                    <?php elseif($row['status'] == 2):?>
                                                                        <?php if(check_authorize("Review","List","verify")):?>
                                                                        <a href="javascript:;" class="edit_status" data_status = "0">待审核</a>|
                                                                        <a href="javascript:;" class="edit_status" data_status = "1">通过</a>|
                                                                        <?php endif;?>
                                                                        <?php if(check_authorize("Review","List","delete")):?>
                                                                        <a href="javascript:;" class="edit_status" data_status = "-1">删除</a>
                                                                        <?php endif;?>
                                                                    <?php elseif($row['status'] == -1):?>
                                                                        <?php if(check_authorize("Review","List","verify")):?>
                                                                        <a href="javascript:;" class="edit_status" data_status = "0">待审核</a>|
                                                                        <a href="javascript:;" class="edit_status" data_status = "1">通过</a>|
                                                                        <a href="javascript:;" class="edit_status" data_status = "2">不通过</a>
                                                                        <?php endif;?>
                                                                    <?php endif;?>
                                                                </td>
                                                         </tr>
                                                    <?php endforeach;?>
                                                    <?php endif;?>
                                                     <tr>
                                                        <td align='center' colspan="7">
                                                            <div class="page_links"><?= $page_links?></div>
                                                        </td>
                                                      </tr>
                                                           
                                                        </tbody>
                                                    </table>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!-- /Page Body -->
        </div>
        <!-- /Page Content -->
<script src="<?= STATICURL; ?>js/jquery-2.0.3.min.js"></script>
<script src="<?= STATICURL; ?>layer/layer.js"></script>
<script src="<?= STATICURL; ?>js/wdatepicker/WdatePicker.js"></script>
<?php require_once ADMINVIEWPATH.'admin_footer.php'; ?>
<script>
    $(".J_search").click(function(){
      /*  var endtime = $("#endtime").val();
        var starttime = $("#starttime").val();*/
        var content = $("#content").val();
        var newsid = $("#newsid").val();
        var status = $("#status").val();
        var params={
         /*   'starttime':starttime,
            'endtime':endtime,*/
            'content':content,
            'newsid':newsid,
            'status':status
        };
        location = "/luckydog/review/index?"+$.param(params);
    });
    $(".edit_status").click(function(){
        var id = $(this).parent().attr("data_id");
        var status = $(this).attr("data_status");
        var status_des = "待审核";
        if(status == 1)
        {
            status_des = "审核通过";
        }else if(status == 2)
        {
            status_des = "审核不通过";
        }else if(status == -1)
        {
            status_des = "删除";
        }
        if (confirm("您确定要"+status_des+"吗？")) 
        {
            $.post("/luckydog/review/edit_status",{id:id,status:status},function(res){
                if(res){
                    layer.msg("成功");
                    window.location.reload();
                }else{
                    layer.msg("失败");
                }
            });
        }
        
    });
</script>



